import React, { Component } from 'react';
import CustomBreadcrumb from '../../components/CustomBreadcrumb';
import TabTable from './components/TabTable';
import axios from 'axios'
import './PostList.scss';

export default class PostList extends Component {
  static displayName = 'PostList';

  constructor(props) {
    super(props);
    this.state = {
      dataSource: []
    };
  }
  componentWillMount() {
    this.getData();
  }
  getData = () => {
    axios.get('http://zzuisa.cn/reader/article/list')
      .then((res) => {


        if (res.data.code === 0) {
          this.setState({
            dataSource: res.data.data
          })
        }
      })
  }
  render() {
    const { dataSource } = this.state
    const breadcrumb = [
      { text: '文章管理', link: '' },
      { text: '文章列表', link: '#/post/list' },
    ];
    return (
      <div className="post-list-page">
        <CustomBreadcrumb dataSource={breadcrumb} />
        <TabTable
          dataSource={this.state.dataSource}
        />
      </div>
    );
  }
}
